/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package atag.runtime.ln.neighborhoodDefs;

import java.util.Iterator;
import java.util.Vector;
import atag.runtime.ln.nodeAttributes.IntegerAttribute;
import atag.runtime.ln.nodeAttributes.Node;
import atag.runtime.ln.nodeAttributes.NodeAttribute;
import atag.runtime.ln.nodeAttributes.StringAttribute;

/**
 *
 * @author mahanth
 */
public class PredicateExtractor {
    public static boolean getPhysicalScope(Neighborhood ln, Node node)
    {
        Iterator it = node.getNodeAttributes().iterator();
        Vector attributes = new Vector();
        NodeAttribute na = null;
       while(it.hasNext())
       {
           Object o = it.next();
           if (o instanceof IntegerAttribute)
           {
               IntegerAttribute ia = (IntegerAttribute)o;
               if (ia.getKey().equals("Room"))
               {
                   na = ia;
               }
           }
       }
       ConjunctiveNeighborhood cn = (ConjunctiveNeighborhood)ln ;
       Vector predicates = cn.getPredicates();
       Vector physicalScopePredicates = new Vector();
        for (int i = 0; i < predicates.size() ; i++)
        {
            if(predicates.elementAt(i) instanceof IntegerSimplePredicate)
            {
                Predicate ip = (Predicate)predicates.elementAt(i);
               if(ip.matches(na))
               {
                   return true;
               }
            }
        }
       return false ;

    }
    
}

